// components/watermark/watermark.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    text: '',
    color: 'rgba(0,0,0,0.1)',
    rows: [],
    cols: []
  },

  /**
   * 组件的方法列表
   */
  methods: {

  },

  // 组件在页面上挂载时触发,注意如果页面没卸载过，该事件就不会触发第二次
  attached() {
    const companyName = wx.getStorageSync('companyName');
    const name = wx.getStorageSync('name');
    const { screenWidth, screenHeight } = wx.getSystemInfoSync();
    const rows = Math.ceil(screenWidth / (14 * (companyName.length >= 4 ? companyName.length : 4) + 45));
    const cols = Math.ceil(screenHeight / 114);
    this.setData({
      text: companyName + '\n' + name,
      rows: new Array(rows),
      cols: new Array(cols)
    });
  }
})
